﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace SHCP
{
    /// <summary>
    /// 基本窗体
    /// </summary>
    public class WindowBase
    {
        public string Name { get; set; }
        public IntPtr Window { get; set; }
        public Rectangle Rect
        {
            get
            {
                return _rect;
            }
        }
        private Rectangle _rect;

        public WindowBase(string name)
        {
            Name = name;
            Window = Win32API.FindWindow(null, name);
            Win32API.GetWindowRect(Window, ref _rect);
        }


        public void Active()
        {
            Win32API.SetForegroundWindow(Window);
        }


        public void Click(int x, int y)
        {
            WinHelper.Click(x + Rect.Left, y + Rect.Top);
        }
    }
}
